<template>
  <el-dialog title="商品入库"
             :visible.sync="dialogFormVisible">
    <el-form>
      <el-form-item label="商品名称"
                    :label-width="formLabelWidth">
        <el-input v-model="goods.name"
                  autocomplete="off"
                  class="ips"
                  disabled></el-input>
      </el-form-item>
      <el-form-item label="仓库数量"
                    :label-width="formLabelWidth">
        <el-input v-model="goods.num"
                  autocomplete="off"
                  class="ips"
                  disabled></el-input>
      </el-form-item>
      <el-form-item label="入库数量"
                    :label-width="formLabelWidth">
        <el-input v-model="goods.pull_num"
                  autocomplete="off"
                  class="ips"></el-input>
      </el-form-item>

    </el-form>
    <div slot="footer"
         class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary"
                 @click="submit()">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {

  data () {
    return {
      dialogFormVisible: false,
      goods: {},
      formLabelWidth: '120px'
    }
  },
  methods: {
    open (id) {
      this.getById(id);
      this.dialogFormVisible = true
    },
    getById (id) {
      this.axios.post('/goods/getById', { id: id }).then(res => {
        if (res.data.code == '2000') {
          this.goods = res.data.data[0]
        }
      })
    },
    submit () {
      this.axios.post('/goods/pull', this.goods, { isTip: true }).then(res => {
        if (res.data.code == '2000') {
          this.dialogFormVisible = false
          this.$parent.getGoodsList();
        }
      })
    }
  }

}
</script>

<style lang="less" scoped>
.ips {
  width: 60%;
}
</style>